import { expect, test } from 'vitest'
import { accounts } from '../../../test/src/constants.js'
import { signMessage } from '../../accounts/index.js'
import { parseErc8010Signature } from './parseErc8010Signature.js'

test('default', async () => {
  const signature = await signMessage({
    message: 'hello world',
    privateKey: accounts[0].privateKey,
  })

  expect(parseErc8010Signature(signature)).toEqual({
    signature,
  })

  expect(
    parseErc8010Signature(
      '0xa461f509887bd19e312c0c58467ce8ff8e300d3c1a90b608a760c5b80318eaf15fe57c96f9175d6cd4daad4663763baa7e78836e067d0163e9a2ccf2ff753f5b1b00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003c35d6df195a251dca39364c71144c91dbf3530aae6461521a9f4455401e43681e0af8f6b2c79db6e58a31585915d2c3fb060707fd8678ec5cfd4dbae2c3730e000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb9226600000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000004deadbeef0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001408010801080108010801080108010801080108010801080108010801080108010',
    ),
  ).toMatchInlineSnapshot(`
    {
      "address": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
      "authorization": {
        "address": "0x0000000000000000000000000000000000000000",
        "chainId": 1,
        "nonce": 0,
        "r": "0x3c35d6df195a251dca39364c71144c91dbf3530aae6461521a9f4455401e4368",
        "s": "0x1e0af8f6b2c79db6e58a31585915d2c3fb060707fd8678ec5cfd4dbae2c3730e",
        "yParity": 0,
      },
      "data": "0xdeadbeef",
      "signature": "0xa461f509887bd19e312c0c58467ce8ff8e300d3c1a90b608a760c5b80318eaf15fe57c96f9175d6cd4daad4663763baa7e78836e067d0163e9a2ccf2ff753f5b1b",
    }
  `)
})
